/*$(document).ready(function() {

	var table = $('#dataTables-example').DataTable({
		"responsive" : true,
		"ajax" : 'getAll.do',
		"columns" : [ {
			"data" : "id",
		}, {
			"data" : "username",
		}, {
			"data" : "password"
		}]
	});
	$("#button1").click(function(){
		
	});
});*/

$(document).ready(function() {
	var table = $('#dataTables-usertable').DataTable({
		 "bProcessing" : false, //是否显示加载
		 "sAjaxSource" : 'getAll.do', //请求资源路径
		 "serverSide": true, //开启服务器处理模式
		 /*
		 使用ajax，在服务端处理数据
		 sSource:即是"sAjaxSource"
		 aoData:要传递到服务端的参数
		 fnCallback:处理返回数据的回调函数
		 */
		 "fnServerData": function(sSource, aoData, fnCallback){
			 $.ajax({ 
				 "type" : 'post', 
				 "url": sSource, 
				 "dataType": "json", 
				 "data": { "aodata" : JSON.stringify(aoData) },
				 "success": function(resp) { 
					 fnCallback(resp);
				 } 
			 }); 
		 }, 
		 "columns" : [ 
			 { data : "id" }, 
			 { data : "username" }, 
			 { data : "password" }, 
		 ]
	});
	
	$('#dataTables-usertable tbody').on('click', 'tr', function() {
		
		if ($(this).hasClass('selected')) {
			$(this).removeClass('selected');
		} else {
			table.$('tr.selected').removeClass('selected');
			$(this).addClass('selected');
		}
	});
	
});